<%--
  Created by IntelliJ IDEA.
  User: 陈金平
  Date: 2020/11/18
  Time: 15:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<html lang="zh-cn">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script type="text/javascript">
        function searchDoctors(page, size) {
            $("#search-form").attr("action", "/all_doctors?page="+page+"&size="+size);
            $("#search-form").submit();
        }
    </script>
    <title>医生列表</title>
</head>

<body>
<h1 class="text-center pt-3 pb-3">医生列表</h1>

<div class="container">
    <div class="offset-md-2 col-md-8">
        <div class="row">
            <div class="col-md-10">
                <form method="post" class="form-inline" role="form" id="search-form">
                    <div class="form-group">
                        <label>科室查询：</label>
                        <select class="form-control form-control-sm" name="pub">
                            <option value="0">全部科室</option>
                            <c:forEach items="${departments}" var="d" >
                                <option value="${d.did}" ${pub==d.did ? "selected":""}>${d.dname}</option>
                            </c:forEach>
                        </select>
                        &nbsp;&nbsp;
                        <button type="submit" onclick="searchDoctors(1,${doctorPage.pageSize})" class="btn btn-sm btn-outline-secondary">查询</button>
                    </div>
                </form>
            </div>
            <div class="col-md-2">
                <form class="form-inline">
                    <div class="form-group">
                        <button type="button" onclick="window.open('/goto_add_doctor')" class="btn btn-sm btn-outline-secondary">新增医生</button>
                    </div>
                </form>
            </div>
        </div>

        <hr>

        <form>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>姓名</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>科室</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <c:forEach items="${doctorPage.doctorList}" var="o" >
                    <tr>
                        <td>${o.id}</td>
                        <td>${o.name}</td>
                        <td>${o.sex}</td>
                        <td>${o.age}</td>
                        <td>${o.dname}</td>
                        <td>
                            <a href="/goto_set_doctor?id=${o.id}" target="_blank">修改</a> /
                            <a href="/goto_del_doctor?id=${o.id}" target="_blank">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </form>

        <nav class="pb-5 pt-3">
            <ul class="pagination justify-content-center">
                <c:if test="${doctorPage.pageNum==1}">
                    <li class="page-item disabled">
                        <a class="page-link" href="#" tabindex="-1">首页</a>
                    </li>
                </c:if>
                <c:if test="${doctorPage.pageNum>1}">
                    <li class="page-item ">
                        <a class="page-link" href="#"onclick="searchDoctors(1, ${doctorPage.pageSize})" tabindex="-1">首页</a>
                    </li>
                </c:if>
                <c:forEach begin="1" end="${doctorPage.pageCount}" var="i">
                    <c:if test="${doctorPage.pageNum==i}">
                        <li class="page-item active" ><a class="page-link" href="#">${i}</a> </li>
                    </c:if>
                    <c:if test="${doctorPage.pageNum!=i}">
                        <li class="page-item"><a class="page-link" onclick="searchDoctors(${i}, ${doctorPage.pageSize})" href="#">${i}</a> </li>
                    </c:if>
                </c:forEach>
                <c:if test="${doctorPage.pageNum==doctorPage.pageCount}">
                    <li class="page-item disabled">
                        <a class="page-link" href="#">末页</a>
                    </li>
                </c:if>
                <c:if test="${doctorPage.pageNum<doctorPage.pageCount}">
                    <li class="page-item">
                        <a class="page-link" href="#" onclick="searchDoctors(${doctorPage.pageCount}, ${doctorPage.pageSize})">末页</a>
                    </li>
                </c:if>
            </ul>
        </nav>
    </div>
</div>
</body>
</html>
